<?php
class SQLQuery
{
	private $dbHandler;

	/**
	 * @return resource
	 */
	public function getDBHandler()
	{
		return $this->dbHandler;
	}
	
	/**
	 * @return mixed
	 */
	public function connect()
	{
		$this->dbHandler = @mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
		if (mysql_select_db(DB_NAME, $this->dbHandler)) {
			return $this->dbHandler;
		}
		return false;
	}
	
	/**
	 * 
	 * @param string $query
	 * @return resource
	 */
	public function executeQuery($query)
	{
		$handler = $this->connect();
		$result = mysql_query($query, $handler);
		$this->disconnect();
		return $result;
	}

	
	public function selectAll($tableName)
	{
		$query = 'SELECT * FROM ' . $tableName . '';
		$result = $this->executeQuery($query);
		return $result;
	}
	
	public function selectByID($tableName, $id)
	{
		$query = 'SELECT * FROM ' . $tableName . ' WHERE id = ' . $id . '';
		$result = $this->executeQuery($query);
		return $result;
	}
	
	public function getDataObjectsArray()
	{
	
	}
	
	public function selectByCriteria()
	{
	
	}
	
	/**
	 * @return boolean
	 */
	public function disconnect()
	{
		return @mysql_close($this->dbHandler);
	}

}